package java_zuoye_3;

import java.util.ArrayList;
import java.util.Random;

public class Manager extends User{
	private String name;
	private int money;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getMoney() {
		return money;
	}
	public void setMoney(int money) {
		this.money = money;
	}
	public Manager() {
		
	}
	public Manager(String name, int money) {
		this.money = money;
		this.name = name;
	}
	public ArrayList<Integer> send(int totalMoney, int count){
		ArrayList<Integer> red = new ArrayList<>();
		int leftMoney = this.money;
		if(totalMoney > leftMoney) {
			System.out.println("没钱");
			return red;
		}
		this.setMoney(leftMoney - totalMoney);
		int avg = totalMoney / count;
		int mod = totalMoney % count;
		for(int i = 0; i < count - 1; i++) {
			red.add(avg);
		}
		int last = avg + mod;
		red.add(last);
		return red;
	}
	public ArrayList<Integer> sendRandom(int totalMoney, int count) {
		Random r = new Random();
		ArrayList<Integer> red = new ArrayList<>();
		int leftmoney = this.money;
		if(totalMoney > leftmoney) {
			System.out.println("没钱");
			return red;
		}
		int maxmoney = totalMoney/count*2;
		int redmoney = totalMoney;
		for(int i = 0; i < count-1; i++) {
			int outmoney = r.nextInt(1,maxmoney);
			red.add(outmoney);
			redmoney -= outmoney;
			maxmoney = redmoney/count*2;
		}
		red.add(redmoney);
		return red;
	}
}